<?php
namespace data\service;

use data\model\TimeLine;

class TimeLineService extends BaseService{

    // 模型初始化
    public function __construct()
    {
        $this->model = new TimeLine();
    }

    /**
     * 获取相应的内容
     * @desc
     * @param $type
     * @author 16
     * @date 2018/2/24
     */
    public static function getContent($type)
    {
        $contents = TimeLine::where('type',$type)->select();
        $cons = [];
        foreach ($contents as $object)
        {
            $cons[date('Y',strtotime($object->create_time))][date('m',strtotime($object->create_time))][] = $object;
        }

        return $cons;
    }

    /**
     * 获取最近的n条时间轴信息
     * @desc
     * @author 16
     * @date 2018/4/12
     */
    public function getLatelyTimeLine(){
        return $this->model->order('create_time DESC')->where('type',TimeLine::STATUS_TIME_LINE)->limit(5)->select();
    }

    /**
     * 获取最近的n条网站建设信息
     * @desc
     * @author 16
     * @date 2018/4/12
     */
    public function getLatelyWebInfo(){
        return $this->model->order('create_time DESC')->where('type',TimeLine::STATUS_WEB_INFO)->limit(5)->select();
    }
}